home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / wemdemo4.zip / INFO / W3.2 (.txt) < prev    next >
GNU Info File  |  1994-09-21  |  48KB  |  831 lines

  1. This is Info file ../info/w3, produced by Makeinfo-1.56 from the input
  2. file w3.txi.
  3.    This file documents the Emacs-w3 World Wide Web browser.
  4.    Copyright (C) 1993, 1994 William M. Perry
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8. File: w3,  Node: Personal Annotations,  Prev: Group Annotations,  Up: Annotations
  9. Personal Annotations
  10. --------------------
  11.    If you do not want to share your musings about a particular document
  12. with the entire network, you can add a personal annotation that only you
  13. can see.  Personal annotations are stored in a subdirectory in the users
  14. account on the local disk, with a log file that contains information
  15. about what URLs have been annotated and which files contain the
  16. annotations.
  17.    Emacs-w3 looks in the directory specified by
  18. `w3-personal-annotation-directory' (defaults to
  19. `~/.mosaic-personal-annotations').  Any personal annotations for a
  20. document are automatically appended when it is retrieved.
  21.    To add a new personal annotation, type `M-x
  22. w3-add-personal-annotation'.  This puts you in a new buffer, in the mode
  23. specified by `w3-annotation-mode'.  This defaults to `html-mode'.  If
  24. this variable is `nil', or it points to an undefined function, then
  25. `default-major-mode' is consulted.
  26.    A minor mode redefines `C-c C-c' to complete the annotation and
  27. store it on your local disk.
  28.    To delete a personal annotation, you must be reading it.  Once
  29. reading the annotation, type `M-x w3-delete-personal-annotation'.  It
  30. deletes the file containing the annotation, and any references to it in
  31. your log file.
  32.    I do not currently support editing personal annotations.
  33. File: w3,  Node: Controlling Formatting,  Next: General Formatting,  Prev: Top,  Up: Top
  34. Controlling Formatting
  35. **********************
  36.    How Emacs-w3 formats a document is very customizable.  How a
  37. document is displayed depends on whether the user is on a terminal
  38. capable of graphics and a few variables.
  39.    The following sections describe in more detail how to change the
  40. formatting of a document.
  41. * Menu:
  42. * General Formatting::                 Changing general things about a
  43.                                        document.
  44. * Character based terminals::          Changing how a document is
  45.                                        displayed on a non-graphics
  46.                                        terminal (vt100, etc.) or if
  47.                                        `w3-delimit-emphasis' is `t'.
  48. * Smart terminals::                    Getting highlighting of links, etc.
  49.                                        on not-quite-so-dumb terminals (vt100s
  50.                                        and comparable machines)
  51. * Graphics workstations::              Changing how a document is
  52.                                        displayed on a graphics terminal
  53.                                        (Xwindows, Windows, NeXTstep,
  54.                                        OS/2, etc.)
  55. * Inlined images::                     How to specify how Emacs-w3
  56.                                        handles inlined images/mpegs.
  57. File: w3,  Node: General Formatting,  Next: Character based terminals,  Prev: Controlling Formatting,  Up: Controlling Formatting
  58. General formatting conventions
  59. ==============================
  60.                           -------------------
  61.                         Setting the fill column
  62.                           -------------------
  63.    Each time a document is parsed, the `fill-column' is recalculated
  64. using `window-width' and `w3-right-border'.  `w3-right-border' is an
  65. integer specifying how much room at the right edge of the screen to
  66. leave blank.  The `fill-column' is set to `(- (window-width)
  67. `w3-right-border')'.
  68.                           -------------------
  69.                      Formatting of hypertext links
  70.                           -------------------
  71.    If the variable `w3-delimit-links' is non-`nil' (the default for
  72. text-terminals), then hypertext links are surrounded by text specified
  73. by the user.  The variables `w3-link-start-delimiter' and
  74. `w3-link-end-delimiter' control what text is at the start and end of a
  75. hypertext link.  These variables are cons-pairs of two strings.
  76.    If a link has never been visited before (it is not in the global
  77. history), then the `car' of these variables is inserted at the start
  78. and end of the link.  If the link has been visited before, then the
  79. `cdr' is inserted.  So, links look like:
  80.      [[This is a hypertext link]] that has never been visited.
  81.      {{This one, however}} has been seen before at some point in time.
  82.    All reserved characters should be replaced with their HTML[+] entity
  83. definitions.
  84.                           -------------------
  85.                           Formatting of lists
  86.                           -------------------
  87.    There are several different ways to control the formatting of lists.
  88. The most obvious is how deeply they are indented relative to the rest of
  89. the paragraphs in the document.  To control this, you should set the
  90. variables `tab-stop-list' and `tab-width'.  A tab every eight spaces is
  91. considered normal, but I prefer to have a tab every four spaces.  So
  92. `tab-stop-list' would be `'(4 8 12 16 20 24 28 32 36 ...)', and
  93. `tab-width' would be `4'.  I use `setq-default' in my `.emacs' for
  94. these, but you can also use them from `w3-mode-hooks'.  Something like:
  95.      (add-hook 'w3-file-prepare-hooks
  96.                (function
  97.                  (lambda ()
  98.                    (setq tab-stop-width (list 4 8 16 20 24 28 32 36 40 44)
  99.                          tab-width 4))))
  100.    Another thing that is easy to change about lists is the bullet
  101. character put at the front of each list item.  This is controlled by
  102. the variable `w3-list-chars-assoc', which is an assoc list.  This is a
  103. list of lists, each sublist describing what to put at the start of each
  104. particular list type.  The `car' of this list should be the type of
  105. list, in all caps (e.g., `UL').  The rest of the list should consist of
  106. strings to insert at certain levels of lists.  The `n'th element of
  107. this list is used when the list is nested `n + 1' levels.  If the list
  108. is not long enough to define a string for a certain nesting level, then
  109. it defaults to either a '*' or a '.'.
  110.                           -------------------
  111.                    Formatting of directory listings
  112.                           -------------------
  113.    When Emacs-w3 encounters a link to a directory (whether by local
  114. file access or via ftp), it can either create an HTML document on the
  115. fly, or use `dired-mode' to peruse the listing.  The variable
  116. `url-use-hypertext-dired' controls this behavior.
  117.    If the value is `t', Emacs-w3 uses `directory-files' to list them
  118. out and transform the directory into a hypertext document, then pass it
  119. through the parser like any other document.
  120.    If the value is `nil', just pass the directory off to dired using
  121. `find-file'.  Using this option loses all the hypertext abilities of
  122. Emacs-w3, and the users is unable to load documents in the directory
  123. directly into Emacs-w3 by clicking with the mouse, etc.
  124.                           -------------------
  125.                    Formatting of gopher directories
  126.                           -------------------
  127.    There are two different ways of viewing gopher links.  You can use
  128. the built-in support that converts gopher directories into HTML, or you
  129. can use the `gopher.el' package by Scott Snyder snyder@fnald0.fnal.gov.
  130. The variable that controls this is `w3-use-hypertext-gopher'.  If set
  131. to `nil', then `gopher.el' is used.  Any other value causes Emacs-w3 to
  132. use its internal gopher support.  If you use `gopher.el', you lose all
  133. the hypertext capabilities of Emacs-w3.  All the functionality of
  134. `gopher.el' is now available in the hypertext version, and the
  135. hypertext version supports Gopher+ and ASK blocks.
  136.    The main way to control the display of gopher directories is by the
  137. variable `w3-gopher-labels'.  This variable controls the text that is
  138. inserted at the front of each item.  This is an assoc list of gopher
  139. types (as one character strings), and a string to insert just after the
  140. list item.  All the normal gopher types are defined.  Entries should be
  141. similar to: `("0" . "(TXT)")'.  I have tried to keep all the tags to
  142. three characters plus two parentheses.
  143.                           -------------------
  144.                       Creating a horizontal rule
  145.                           -------------------
  146.    Horizontal rules (<HR> tags in HTML[+]) are used to separate chunks
  147. of a document, and is meant to be rendered as a solid line across the
  148. page.  Some terminals display characters differently, so the variable
  149. `w3-horizontal-rule-char' controls which character is used to draw a
  150. horizontal bar.  This variable must be the ASCII value of the character,
  151. not a string.  The variable is passed through make-string whenever a
  152. horizontal rule of a certain width is necessary.
  153. File: w3,  Node: Character based terminals,  Next: Smart terminals,  Prev: General Formatting,  Up: Controlling Formatting
  154. On character based terminals
  155. ============================
  156.    On character based terminals, there is no easy way to show that a
  157. certain range of text is in bold or italics.  If the variable
  158. `w3-delimit-emphasis' is non-`nil', then Emacs-w3 can insert characters
  159. before and after character formatting commands in HTML documents.  The
  160. defaul value of `w3-delimit-emphasis' is automatically set based on the
  161. type of window system and version of Emacs being used.
  162.    Two variables control what text is inserted around different markup
  163. tags.  `w3-header-chars-assoc' controls what characters are inserted
  164. around header items, and `w3-style-chars-assoc' controls what
  165. characters are inserted around most other markup (italics, addresses,
  166. etc.).
  167.    `w3-header-chars-assoc' is an assoc list of header tags and a list
  168. of formatting instructions.  The `car' of the list is the level of the
  169. header (1-6).  The rest of the list should contain three items.  The
  170. first item is text to insert before the header.  The second item is
  171. text to insert after the header.  Both should have reserved characters
  172. converted to their HTML[+] entity definitions.  The third item is a
  173. function to call on the area the header is in.  This function is called
  174. with arguments specifying the start and ending character positions of
  175. the header.  The starting point is always first.  To convert a region to
  176. upper case, please use `w3-upcase-region' instead of `upcase-region',
  177. so that URLs within the region are not corrupted.
  178.    `w3-style-chars-assoc' is an assoc list of style tags and a list of
  179. strings.  The `car' of the list is the type of style tag it specifies
  180. (DFN, B, I, etc.).  The rest of the list should contain two items.  The
  181. `car' is text to insert before the stylized text.  The `cdr' is text to
  182. insert after the stylized text.  Both should have reserved characters
  183. converted to their HTML[+] entity definitions.
  184. File: w3,  Node: Smart terminals,  Next: Graphics workstations,  Prev: Character based terminals,  Up: Controlling Formatting
  185.    If using Emacs 19.2x on a VT100 compatible terminal, Emacs-w3 can
  186. show links, headers, and various other types of emphasis in bold or
  187. underlined text.
  188.    To do this, you should set the variable `w3-emacs19-hack-faces-p' to
  189. non-`nil' in your `~/.emacs' file.  You should also make sure that the
  190. environment variable `TERM' is set to the correct terminal type that
  191. you are using.
  192.    If there is a function called `w3-emacs19-hack-TERMINAL', then this
  193. is used to setup the special characters that turn on bold and
  194. underlined text.  If this function does not exist, you can write one
  195. from scratch, using your terminals entry in the `/etc/termcap' file.
  196.    Each function should use the `standard-display-table' to replace ^A,
  197. ^B, ^C, and ^D with escape sequences that turn on highlighting.  When
  198. reading your `/etc/termcap' file, be on the lookout for these codes:
  199.      Code to turn on underlining
  200.      Code to turn off underlining
  201.      Code to turn on boldface type
  202.      Code to turn off all attributes
  203.    Here is an example for creating the VT100 control sequences:
  204.      (defun w3-emacs19-hack-vt100 ()
  205.        "Hack 'faces' for ttys (vt100)"
  206.        (or standard-display-table
  207.            (setq standard-display-table (make-vector 261 nil)))
  208.        (aset standard-display-table 1 (vector (create-glyph "\e[4m")))
  209.        (aset standard-display-table 2 (vector (create-glyph "\e[m")))
  210.        (aset standard-display-table 3 (vector (create-glyph "\e[5m")))
  211.        (aset standard-display-table 4 (vector (create-glyph "\e[m")))
  212.        )
  213.    To turn off the highlighting features, set the variable
  214. `w3-emacs19-hack-faces-p' to `nil' and execute the function
  215. `w3-emacs19-unhack-faces'
  216.    NOTE: This highlighting is not perfect and could cause some odd
  217. display glitches, especially when Emacs does a smart redisplay and
  218. doesn't redraw the whole screen.  `C-l' usually fixes these problems.
  219. File: w3,  Node: Graphics workstations,  Next: Inlined images,  Prev: Smart terminals,  Up: Controlling Formatting
  220. With graphics workstations
  221. ==========================
  222.    When you are running in a graphic environemnt (Xwindows or NeXTstep
  223. for example), the fonts and colors used by Emacs-w3 to display text can
  224. be controlled by setting a few resources.  To specify these resources:
  225.    * Xwindows: Place them into your `~/.Xresources' file or the
  226.      `/usr/lib/X11/app-defaults/Emacs' file.
  227.    * NeXTstep: If you are using the NeXTstep port of Emacs 19, you
  228.      should use the `dwrite' command to install these resources.  The
  229.      command should look something like: (`dwrite Emacs
  230.      <Style>.Attribute<item> value', where style and attribute are one
  231.      of the choices below.
  232.    * OS/2 or Windows: If you are using the Lucid Emacs or FSF Emacs
  233.      that has been ported to the Presentation Manager or Windows 3.x,
  234.      it tells you where to store a file that Emacs looks at for
  235.      Xresources.  The resources for each version of Emacs are the same.
  236. For each style of text that Emacs-w3 uses, you can specify any of the
  237. following resources by replacing <style> with the actual style name.
  238.    * Emacs*<Style>.AttributeFont: Font name
  239.    * Emacs*<Style>.AttributeForeground: Foreground color
  240.    * Emacs*<Style>.AttributeBackground: Background color
  241.    * Emacs*<Style>.AttributeUnderline: Underline text?
  242.    Emacs-w3 uses these style names:
  243. `w3-address-style'
  244.      For anything in <ADDRESS> tags.
  245. `w3-bold-style'
  246.      For anything in bold, strong, or a definition
  247. `w3-default-style'
  248.      For normal text
  249. `w3-header-style'
  250.      For any headers
  251. `w3-italic-style'
  252.      For italic text, emphasized, or addresses
  253. `w3-node-style'
  254.      For links to other documents
  255. `w3-strikethru-style'
  256.      For items that should be shown as struck-out.
  257. `w3-subscript-style'
  258.      For subscripted items
  259. `w3-superscript-style'
  260.      For superscripted items
  261. `w3-tt-style'
  262.      For fixed width fonts, code segments, samples, or variables
  263. `w3-underline-style'
  264.      For underlining, and citations
  265. `w3-visited-node-style'
  266.      For displaying hypertext links that have been viewed before
  267.    To determine what styles are displayed in what face, Emacs-w3 uses
  268. an assoc list called `w3-style-assoc'.  It is of the form `(TAGNAME .
  269. FACENAME)', where tagname is the HTML[+] tag that surrounds the text
  270. (without the <, >, or /), and FACENAME is either a symbol representing a
  271. face (in Emacs 19 and Lucid Emacs) or a symbol representing a variable
  272. that holds the face information (Epoch 4.x).
  273. File: w3,  Node: Inlined images,  Prev: Graphics workstations,  Up: Controlling Formatting
  274.    When running in Lucid Emacs 19.10 or XEmacs 19.11, Emacs-w3 can
  275. display inlined images and MPEG movies.  There are several variables
  276. that control how and when the images are displayed.
  277.    Since Lucid/XEmacs only natively understands XPixmaps and XBitmaps,
  278. GIFs and other image types must first be converted to one of these
  279. formats.  To do this, the netpbm utilities(1) programs are normally
  280. used.  This is a suite of freeware image conversion tools.  The
  281. variable `w3-graphic-converter-alist' controls how each image type is
  282. converted.  This is an assoc list, keyed on the MIME content-type.  The
  283. `car' is the content-type, and the `cdr' is a string suitable to pass
  284. to `format'.  A %s in this string will be replaced with a converter
  285. from the ppm image format to an XPixmap (or XBitmap, if being run on a
  286. monochrome display).  By default, the emacs-w3 browser has converters
  287.   1. image/x-xbitmap
  288.   2. image/xbitmap
  289.   3. image/xbm
  290.   4. image/gif
  291.   5. image/x-fax
  292.   6. image/x-raster
  293.   7. image/windowdump
  294.   8. image/x-icon
  295.   9. image/portable-graymap
  296.  10. image/portable-pixmap
  297.  11. image/x-pixmap
  298.  12. image/x-xpixmap
  299.  13. image/pict
  300.  14. image/x-macpaint
  301.  15. image/x-targa
  302.  16. image/tiff
  303.    Since most displays are not 24-bit, Emacs-w3 can automatically
  304. dither an image, so that it does not fill up the application' colormap
  305. too quickly.  If `w3-color-use-reducing' is non-`nil', then the images
  306. will use reduced colors.  If `w3-color-filter' is `eq' to `'ppmquant',
  307. then the ppmquant program will be used.  If `eq' to `'ppmdither', then
  308. the ppmdither program will be used.  The ppmdither program tends to
  309. give better results.  The values of `w3-color-max-red',
  310. `w3-color-max-blue', and `w3-color-max-green' control how many colors
  311. the inlined images can use.  If using ppmquant, then the product of
  312. these three variables is used as the maximum number of colors per
  313. image.  If using ppmdither, then only the set number of color cells can
  314. be allocated per image.  See the man pages for ppmdither and ppmquant
  315. for more information on how the dithering is actually done.
  316.    :: WORK ::
  317.    w3-delay-image-loads w3-delay-mpeg-loads
  318.    w3-load-delayed-images w3-load-delayed-mpegs
  319.    w3-graphics-entities-alist w3-graphics-always-show-entities
  320.    ---------- Footnotes ----------
  321.    (1)  Available via anonymous ftp from
  322. ftp.x.org:/R5contrib/netpbm-1mar1994.tar.gz, and most large ftp sites.
  323. File: w3,  Node: HTTP/1.0 Support,  Next: Redirection,  Prev: Top,  Up: Top
  324. HTTP/1.0 Support
  325. ****************
  326.    The new revision of the HTTP specification adds much more
  327. functionality to the server side of a transaction.  Access
  328. authorization has been added, and several types of redirection can
  329. occur.  All of this negotiation and redirection should take place
  330. before the user ever sees the first requested page--this avoids the
  331. overhead of parsing any error messages or old documents the server may
  332. have returned with the redirection or authorization message.  The new
  333. protocol is also MIME (Multimedia Internet Mail Extensions, see RFC
  334. 1341) compliant.
  335. * Menu:
  336. * Redirection::
  337. * Authentication::                      Accessing restricted servers and
  338.                                         documents
  339. * Payment::                             How to pay for services over the
  340.                                         World Wide Web
  341. * MIME Support::                        How Emacs-w3 uses MIME types, and how to
  342.                                         modify its behavior.
  343. File: w3,  Node: Redirection,  Next: Authentication,  Prev: HTTP/1.0 Support,  Up: HTTP/1.0 Support
  344. Redirection
  345. ===========
  346.    One of the most useful aspects of HTTP/1.0 is the ability to
  347. transparently move files between different servers (perhaps even
  348. different protocols).  Most of the WWW browsers support redirection in
  349. some form or another.  The Emacs browser supports all three types of
  350. redirection in the HTTP/1.0 specification (error codes 301, 302, and
  351. 303).
  352.    Whenever a redirection response is detected, the URL specified by the
  353. Location: header is retrieved.  All relative references are resolved
  354. before requesting the new URL.
  355.    Eventually, an HTML editor that is tightly integrated with the
  356. browser is planned, and will include the ability to edit documents to
  357. change their links if a permanent relocation is seen.
  358. File: w3,  Node: Authentication,  Next: Payment,  Prev: Redirection,  Up: HTTP/1.0 Support
  359. Authentication
  360. ==============
  361.    Lots of information is useful to a group of people within an
  362. organization, or a group working on a project, but it is not always wise
  363. to distribute this information to the world at large.
  364.    The HTTP/1.0 protocol adds the capability to have authentication
  365. based on usernames and passwords.  If the improper username/password
  366. pair is sent to the server, an error code of 401, Unauthorized is
  367. returned by the server.
  368.    The browser has a very extensible interface to its authentication
  369. handling.  When a 401 error code is received, the Auth-type header is
  370. checked--this header field should be a space-separated list of suitable
  371. authorization schemes for the requested URL.  The value of this header
  372. is read into a lisp symbol by way of Emacs's read-string function.
  373. This lisp symbol looks like `url-authtype-auth', where authtype is
  374. replaced by the correct authorization type.  The authorization types
  375. defined in the latest HTTP/1.0 specification include user, basic,
  376. public key, and kerberos (versions 4 and 5).  If a function of this
  377. name is currently defined, then the function is called via `funcall'
  378. with several parameters:
  379.   1. The URL being authenticated.
  380.   2. whether to prompt for a username/password if no cached data is
  381.      found.
  382.   3. whether to overwrite an old username/password if the information is
  383.      found in the cache.
  384.         This interface was chosen for its flexibility and
  385. extensibility.  The main routine that does the MIME parsing and the
  386. buil,ding of the Authorization header does not need to know how to
  387. handle each type of authentication, and the addition of a new method
  388. for authentication is simply a matter of defining one function that
  389. conforms to a simple interface.
  390.    The only authorization supported by the browser at this time is
  391. 'basic.' This is simply a string that looks like `user:password' that
  392. has been encoded using Base64 encoding as defined in RFC 1421.  It is
  393. given as an example of how to write an authorization module.  All of the
  394. functions for storing, retrieving, and over-writing the cached
  395. authorization information should all be handled by one function
  396. (although it would be perfectly acceptable to have a stub function that
  397. passed off to three larger functions based on its parameters).  The most
  398. efficient way to store the cached information is by an assoc-list of
  399. assoc-lists.  The top level assoc list is keyed on the name of the
  400. server.  The secondary assoc-list is keyed on the full path of the file
  401. that is protected.  Thus, a sample authorization cache would look like
  402. this:
  403.      ((``info.cern.ch''    . ((``/foo''        . ``d21wZXJyeTp0ZXN0aW5n'')
  404.                               (``/bar''        . ``amtvbnJhdGg6ZGlzbWVtYmVy'')
  405.                               (``/foo/x.html'' . ``dmlvbGV0dDpvcGVuZ2w='')))
  406.       (``cs.indiana.edu''  . ((``/elisp/w3/''  . ``dGxvb3M6Y29ucXVlcg=='')
  407.                               (``/''           . ``bXZhbmhleW46a2lsbGh1bGljaw=='')))
  408.      )
  409.    The structure consists of two assoc-lists for the sake of speed.  The
  410. list of cached information could conceivably hold several thousand links
  411. (if the user does not exit Emacs for long periods of time.)  If the list
  412. were keyed on a full URL, the assoc function would have to search
  413. through every link before failing to find a new URL.  With the current
  414. scheme, assoc only has to search though a few items (maximum is the
  415. number of HTTP servers, which should always be much, much smaller than
  416. the number of distinct URLs.)  Even with a 3:1 ratio of URLs to each
  417. server, this is a big win.
  418. File: w3,  Node: Payment,  Next: MIME Support,  Prev: Authentication,  Up: HTTP/1.0 Support
  419. Payment
  420. =======
  421.    The Chargeto: header will be used to pay for services offered over
  422. the World Wide Web.  Such things as electronic magazines and commercial
  423. databases all need a way to restrict access to only authorized
  424. subscribers.  The format of the header has yet to be specified, but the
  425. interface and storage techniques will be similar to the Authorization
  426. section.
  427. File: w3,  Node: MIME Support,  Next: Adding MIME types based on file extensions,  Prev: Payment,  Up: HTTP/1.0 Support
  428. MIME Support
  429. ============
  430.    MIME is an emerging standard for multimedia mail.  It offers a very
  431. flexible typing mechanism.  The type of a file/message is specified in
  432. two parts, separated by a '/'.  The first part is a general category of
  433. data (text, application, image, etc.).  The second part is the specific
  434. type of data (postscript, gif, jpeg, etc.).  So `text/html' specifies
  435. an HTML document, whereas `image/x-xwindowdump' specifies an image of
  436. an Xwindow taken with the xwd program.
  437.    This typing allows much more flexibility in naming files.  HTTP/1.0
  438. servers can now send back content-type headers in response to a request,
  439. and not have the client second-guess it based on file extensions.  Now
  440. you can name HTML files `something.gif' if you really felt like it (not
  441. a great idea, but doable).
  442. * Menu:
  443. * Adding MIME types based on file extensions::  How to map file
  444.                                                 extensions onto MIME
  445.                                                 types (e.g., `.gif ->
  446.                                                 image/gif)'.
  447. * Mapping gopher types to MIME types::          Going from gopher typing
  448.                                                 to MIME types.
  449. * Specifying Viewers::  How to specify external and internal viewers
  450.                         for files that Emacs-w3 cannot handle natively.
  451. * Mailcap File::        How to set up and use a Mailcap file.  Standard
  452.                         way to specify MIME viewers - compatible with
  453.                         Mosaic and most MIME compliant mailers.
  454. File: w3,  Node: Adding MIME types based on file extensions,  Next: Mapping gopher types to MIME types,  Prev: MIME Support,  Up: MIME Support
  455. Adding MIME types based on file extensions
  456. ------------------------------------------
  457.    For some protocols however, it is still necessary to guess the
  458. content of a file based on the file extension.  This type of guess-work
  459. should only be needed when accessing files via FTP, local file access,
  460. or old HTTP/0.9 servers.
  461.    Instead of specifying how to view things twice, once based on
  462. content-type and once based on the file extension, it is easier to map
  463. file extensions to MIME content-types.  The variable that controls this
  464. is `mm-mime-extensions'.
  465.    This variable is an assoc list of file extensions and the
  466. corresponding MIME content-type.  A sample entry looks like: `(".movie"
  467. . "video/x-sgi-movie")' This makes all files that end in `.movie'
  468. (`foo.movie' and `bar.movie') be interpreted as SGI animation files.
  469. If a content-type is defined for the document, then this is
  470. over-ridden.  Regular expressions can NOT be used.
  471.    Both Mosaic and the NCSA HTTP daemon rely on a separate file for
  472. mapping file extensions to MIME types.  Instead of having the users of
  473. Emacs-w3 duplicate this in lisp, this file can be parsed using the
  474. `url-parse-mimetypes' function.  This function is called each time w3
  475. is loaded.  It tries to locate mimetype files in several places. If the
  476. environment variable `MIMETYPES' is nonempty, then this is assumed to
  477. specify a UNIX-like path of mimetype files (this is a colon separated
  478. string of pathnames).  If the `MIMETYPES' environment variable is
  479. empty, then Emacs-w3 looks for these files:
  480.   1. `~/.mime-types'
  481.   2. `/etc/mime-types'
  482.   3. `/usr/etc/mime-types'
  483.   4. `/usr/local/etc/mime-types'
  484.   5. `/usr/local/www/conf/mime-types'
  485.    Each line contains information for one http type.  These types
  486. resemble MIME types.  If you plan to add new ones, you should use
  487. subtypes beginning with x-, such as application/x-myprogram.  Lines
  488. beginning with # are comment lines, and suitably ignored.  Each line
  489. consists of:
  490.    type/subtype ext1 ext2 ...  extN
  491.    type/subtype is the MIME-like type of the document. ext* is any
  492. number of space-separated filename extensions which correspond to the
  493. MIME type.
  494. File: w3,  Node: Mapping gopher types to MIME types,  Next: Specifying Viewers,  Prev: Adding MIME types based on file extensions,  Up: MIME Support
  495. Mapping gopher types to MIME types
  496. ----------------------------------
  497.    Need to fill this in :: WORK ::
  498. File: w3,  Node: Specifying Viewers,  Next: Mailcap File,  Prev: Mapping gopher types to MIME types,  Up: MIME Support
  499. Specifying Viewers
  500. ------------------
  501.    Not all files look as they should when parsed as an HTML document
  502. (whitespace is stripped, paragraphs are reformatted, and lots of little
  503. changes that make the document look unrecognizable).  Files may be
  504. passed to external programs or Emacs Lisp functions to be viewed.
  505.    Not all files can be viewed accurately from within an Emacs session
  506. (GIF files for example, or audio files).  For this reason, the user can
  507. specify file "viewers" based on MIME content-types.  The variable
  508. `w3-mime-viewers' is an assoc-list contains MIME content-types and a
  509. lisp object specifying how to view a document.
  510.    If the lisp object is a string (e.g., `"xv -perfect %s"'), it
  511. specifies an external program that should be used to view the document.
  512. This is passed through the `format' function.  The first %s is replaced
  513. with the temporary file name the retrieved document is saved in, and
  514. then that resulting string is used as a command in a subprocess via
  515. `start-process'.
  516.    If the lisp object is a lisp symbol (e.g., `tar-mode'), it species a
  517. lisp function to call after visiting the buffer.  This is appropriate
  518. for using major modes to view documents.  The function is called with no
  519. arguments.
  520.    If the lisp object is a list (e.g., `(message "wow")'), it specifies
  521. something to be passed through `eval'.
  522. File: w3,  Node: Mailcap File,  Prev: Specifying Viewers,  Up: MIME Support
  523. Mailcap File
  524. ============
  525.    NCSA Mosaic and almost all other WWW browsers rely on a separate file
  526. for mapping MIME types to external viewing programs.  This takes some of
  527. the burden off of browser developers, so each browser does not have to
  528. support all image formats, or postscript, etc.  Instead of having the
  529. users of Emacs-w3 duplicate this in lisp, this file can be parsed using
  530. the `mm-parse-mailcaps' function.  This function is called each time w3
  531. is loaded.  It tries to locate mimetype files in several places. If the
  532. environment variable `MAILCAPS' is nonempty, then this is assumed to
  533. specify a UNIX-like path of mimetype files (this is a colon separated
  534. string of pathnames).  If the `MAILCAPS' environment variable is empty,
  535. then Emacs-w3 looks for these files:
  536.   1. `~/.mailcap'
  537.   2. `/etc/mailcap'
  538.   3. `/usr/etc/mailcap'
  539.   4. `/usr/local/etc/mailcap'
  540.    This format of this file is specified in RFC 1343, but a brief
  541. synopsis follows (this is taken verbatim from sections of RFC 1343).
  542.    Each mailcap file consists of a set of entries that describe the
  543. proper handling of one media type at the local site.  For example, one
  544. line might tell how to display a message in Group III fax format.  A
  545. mailcap file consists of a sequence of such individual entries,
  546. separated by newlines (according to the operating system's newline
  547. conventions). Blank lines and lines that start with the "#" character
  548. (ASCII 35) are considered comments, and are ignored.  Long entries may
  549. be continued on multiple lines if each non-terminal line ends with a
  550. backslash character ('\', ASCII 92), in which case the multiple lines
  551. are to be treated as a single mailcap entry.  Note that for such
  552. "continued" lines, the backslash must be the last character on the line
  553. to be continued.
  554.    Each mailcap entry consists of a number of fields, separated by
  555. semi-colons.  The first two fields are required, and must occur in the
  556. specified order.  The remaining fields are optional, and may appear in
  557. any order.
  558.    The first field is the content-type, which indicates the type of data
  559. this mailcap entry describes how to handle.  It is to be matched against
  560. the type/subtype specification in the "Content-Type" header field of an
  561. Internet mail message.  If the subtype is specified as "*", it is
  562. intended to match all subtypes of the named content-type.
  563.    The second field, view-command, is a specification of how the
  564. message or body part can be viewed at the local site.  Although the
  565. syntax of this field is fully specified, the semantics of program
  566. execution are necessarily somewhat operating system dependent.
  567.    The optional fields, which may be given in any order, are as follows:
  568.    * The "compose" field may be used to specify a program that can be
  569.      used to compose a new body or body part in the given format.  Its
  570.      intended use is to support mail composing agents that support the
  571.      composition of multiple types of mail using external composing
  572.      agents.  As with the view- command, the semantics of program
  573.      execution are operating system dependent.  The result of the
  574.      composing program may be data that is not yet suitable for mail
  575.      transport--that is, a Content-Transfer-Encoding may need to be
  576.      applied to the data.
  577.    * The "composetyped" field is similar to the "compose" field, but is
  578.      to be used when the composing program needs to specify the
  579.      Content-type header field to be applied to the composed data.  The
  580.      "compose" field is simpler, and is preferred for use with existing
  581.      (non-mail-oriented) programs for composing data in a given format.
  582.      The "composetyped" field is necessary when the Content-type
  583.      information must include auxilliary parameters, and the
  584.      composition program must then know enough about mail formats to
  585.      produce output that includes the mail type information.
  586.    * The "edit" field may be used to specify a program that can be used
  587.      to edit a body or body part in the given format.  In many cases,
  588.      it may be identical in content to the "compose" field, and shares
  589.      the operating-system dependent semantics for program execution.
  590.    * The "print" field may be used to specify a program that can be
  591.      used to print a message or body part in the given format.  As with
  592.      the view-command, the semantics of program execution are operating
  593.      system dependent.
  594.    * The "test" field may be used to test some external condition (e.g.
  595.      the machine architecture, or the window system in use) to
  596.      determine whether or not the mailcap line applies.  It specifies a
  597.      program to be run to test some condition.  The semantics of
  598.      execution and of the value returned by the test program are
  599.      operating system dependent.  If the test fails, a subsequent
  600.      mailcap entry should be sought.  Multiple test fields are not
  601.      permitted--since a test can call a program, it can already be
  602.      arbitrarily complex.
  603.    * The "needsterminal" field indicates that the view-command must be
  604.      run on an interactive terminal.  This is needed to inform
  605.      window-oriented user agents that an interactive terminal is
  606.      needed.  (The decision is not left exclusively to the view-command
  607.      because in some circumstances it may not be possible for such
  608.      programs to tell whether or not they are on interactive
  609.      terminals.)  The needsterminal command should be assumed to apply
  610.      to the compose and edit commands, too, if they exist.  Note that
  611.      this is NOT a test--it is a requirement for the environment in
  612.      which the program will be executed, and should typically cause the
  613.      creation of a terminal window when not executed on either a real
  614.      terminal or a terminal window.
  615.    * The "copiousoutput" field indicates that the output from the
  616.      view-command will be an extended stream of output, and is to be
  617.      interpreted as advice to the UA (User Agent mail- reading program)
  618.      that the output should be either paged or made scrollable. Note
  619.      that it is probably a mistake if needsterminal and copiousoutput
  620.      are both specified.
  621.    * The "description" field simply provides a textual description,
  622.      optionally quoted, that describes the type of data, to be used
  623.      optionally by mail readers that wish to describe the data before
  624.      offering to display it.
  625.    * The "x11-bitmap" field names a file, in X11 bitmap (xbm) format,
  626.      which points to an appropriate icon to be used to visually denote
  627.      the presence of this kind of data.
  628.    * Any other fields beginning with "x-" may be included for local or
  629.      mailer-specific extensions of this format.  Implementations should
  630.      simply ignore all such unrecognized fields to permit such
  631.      extensions, some of which might be standardized in a future
  632.      version of this document.
  633. File: w3,  Node: Advanced Features,  Next: Searching,  Up: Top
  634. Advanced Features
  635. *****************
  636. * Menu:
  637. * Searching::        How to search entire sections of the web
  638.             for what you want, automatically.
  639. * Interfacing to VM::    How to make VM understand hypertext links
  640. * Interfacing to RMAIL::How to make RMAIL understand hypertext links
  641. * Interfacing to GNUS::    How to make GNUS understand hypertext links
  642. * Using PGP/PEM::    How to use various public-key crypto-systems
  643.             to ensure the security of your HTTP
  644.                         transactions.
  645. * Native WAIS Support:: How to make Emacs-w3 understand WAIS links without
  646.                         using a gateway.
  647. * Rating Links::        How to make Emacs-w3 put an 'interestingness' value
  648.                         next to each link.
  649. * Gopher Plus Support:: How Emacs-w3 makes use of the Gopher+ protocol.
  650. * Hooks::               Various hooks to use throughout Emacs-w3
  651. * Other Variables::     Miscellaneous variables that control the real
  652.                         guts of Emacs-w3.
  653. File: w3,  Node: Searching,  Next: Interfacing to VM,  Prev: Advanced Features,  Up: Advanced Features
  654. Searching
  655. =========
  656.    In the file `w3-search.el' is a function that some of you may find
  657. handy.  It is not 100% completed yet, so if you run into any problems
  658. with it, please try to fix it, not just say its broken.
  659.    The function is `w3-do-search'.  It must be called with at least one
  660. argument.  All others are optional.  Arguments are TERM, BASE,
  661. HOPE-LIMIT, and RESTRICTION.  This recursively descends all the child
  662. links of the current document for TERM.  TERM may be a string, in which
  663. case it is treated as a regular expression, and `re-search-forward' is
  664. used, or a symbol, in which case it is funcalled with 1 argument, the
  665. current URL being searched.
  666.    BASE is the URL to start searching from.
  667.    HOPS-LIMIT is the maximum number of nodes to descend before the
  668. search dies out.
  669.    RESTRICTION is a regular expression or function to call with one
  670. argument, a URL that could be searched.  If RESTRICTION returns
  671. non-`nil', then the URL is added to the queue, otherwise it is
  672. discarded.  This is useful for restricting searching to either certain
  673. types of URLs (only search ftp links), or restricting searching to one
  674. domain (only search stuff in the indiana.edu domain).
  675.    You may check several variables from the main `w3-do-search' routine
  676. in any functions passed to it (as RESTRICTION or TERM). QUEUE is the
  677. queue of links to be searched, HOPS is the current number of hops from
  678. the root document, RESULTS is an assoc list of (URL . RETVAL), where
  679. RETVAL is the value returned from previous calls to the TERM function
  680. (or point if searching for a regular expression).
  681.    The function returns a list of the form: ((URL . RETVAL)...)
  682.    Please note that there is no interactive use for this function
  683. yet--it was designed for non-interactive, batch-mode processing.
  684. However, if anyone wants to write a wrapper function for it, please feel
  685. free.
  686. File: w3,  Node: Interfacing to VM,  Next: Interfacing to RMAIL,  Prev: Searching,  Up: Advanced Features
  687. Interfacing to VM
  688. =================
  689.    More and more people are including URLs in their signatures, and
  690. within the body of mail messages.  It can get quite tedious to type
  691. these into the minibuffer when you wish to follow one.  The following
  692. functions in your `~/.emacs' or `~/.vm' files should do the trick.  It
  693. adds two keybindings to the main VM message window.  The middle mouse
  694. button now tries to follow a hypertext link.  This first tries to find
  695. any links that were fully-qualified with the HTML <A> and </A> (1) tags,
  696. otherwise it checks to see if the text around point is a naked URL (2).
  697. `w3-build-links-list' should not be run on a VM or RMAIL buffer, since
  698. it will modify the buffer contents (and therefore the actual mail
  699. message), and there is no way to revert the message short of reverting
  700. the entire mail folder.
  701.      (defun w3-maybe-follow-link-mouse (e)
  702.        "Maybe follow a hypertext link under point.
  703.      If there is no link under point, this will try using
  704.      url-get-url-at-point"
  705.        (interactive "e")
  706.        (save-excursion
  707.          (mouse-set-point e)
  708.          (w3-maybe-follow-link)))
  709.      
  710.      (defun w3-maybe-follow-link ()
  711.        "Maybe follow a hypertext link under point.
  712.      If there is no link under point, this will try using
  713.      url-get-url-at-point"
  714.        (interactive)
  715.        (require 'w3)
  716.        (if (not w3-setup-done) (w3-do-setup))
  717.        (let* ((zn  (w3-zone-at (point)))
  718.               (url1 (and zn (w3-zone-data zn)))
  719.               (url2 (url-get-url-at-point)))
  720.          (cond
  721.            (url1 (w3-follow-link))
  722.            ((and url2 (string-match url-nonrelative-link url2)) (w3-fetch url2))
  723.            (t (message "w3-maybe-follow-link got confused.")))))
  724.      
  725.      (add-hook 'vm-mode-hook
  726.                (function
  727.                  (lambda ()
  728.                    (define-key vm-mode-map [mouse-2] 'w3-maybe-follow-link-mouse)
  729.                    (define-key vm-mode-map "\r"      'w3-maybe-follow-link))))
  730.    ---------- Footnotes ----------
  731.    (1)  Something akin to <a href="http://cs.indiana.edu/">
  732.    (2)  Similar to http://cs.indiana.edu/
  733. File: w3,  Node: Interfacing to RMAIL,  Next: Interfacing to GNUS,  Prev: Interfacing to VM,  Up: Advanced Features
  734. Interfacing to RMAIL
  735. ====================
  736.    More and more people are including URLs in their signatures, and
  737. within the body of mail messages.  It can get quite tedious to type
  738. these into the minibuffer when you wish to follow one.  The following
  739. functions in your `~/.emacs' files should do the trick.  It adds two
  740. keybindings to the main RMAIL window.  The middle mouse button now
  741. tries to follow a hypertext link.  This first tries to find any links
  742. that were fully-qualified with the HTML <A> and </A> (1) tags,
  743. otherwise it checks to see if the text around point is a naked URL (2).
  744. `w3-build-links-list' should not be run on a VM or RMAIL buffer, since
  745. it will modify the buffer contents (and therefore the actual mail
  746. message), and there is no way to revert the message short of reverting
  747. the entire mail folder.
  748.      (defun w3-maybe-follow-link-mouse (e)
  749.        "Maybe follow a hypertext link under point.
  750.      If there is no link under point, this will try using
  751.      url-get-url-at-point"
  752.        (interactive "e")
  753.        (save-excursion
  754.          (mouse-set-point e)
  755.          (w3-maybe-follow-link)))
  756.      
  757.      (defun w3-maybe-follow-link ()
  758.        "Maybe follow a hypertext link under point.
  759.      If there is no link under point, this will try using
  760.      url-get-url-at-point"
  761.        (interactive)
  762.        (require 'w3)
  763.        (if (not w3-setup-done) (w3-do-setup))
  764.        (let* ((zn  (w3-zone-at (point)))
  765.               (url1 (and zn (w3-zone-data zn)))
  766.               (url2 (url-get-url-at-point)))
  767.          (cond
  768.            (url1 (w3-follow-link))
  769.            ((and url2 (string-match url-nonrelative-link url2)) (w3-fetch url2))
  770.            (t (message "w3-maybe-follow-link got confused.")))))
  771.      
  772.      (add-hook 'rmail-mode-hook
  773.            (function
  774.             (lambda ()
  775.               (define-key rmail-mode-map [mouse-2] 'w3-maybe-follow-link-mouse)
  776.               (define-key rmail-mode-map "\r"      'w3-maybe-follow-link))))
  777.    ---------- Footnotes ----------
  778.    (1)  Something akin to <a href="http://cs.indiana.edu/">
  779.    (2)  Similar to http://cs.indiana.edu/
  780. File: w3,  Node: Interfacing to GNUS,  Next: Using PGP/PEM,  Prev: Interfacing to RMAIL,  Up: Advanced Features
  781. Interfacing to GNUS
  782. ===================
  783.    More and more people are including URLs in their signatures and
  784. within the body of usenet posts.  It can get quite tedious to type
  785. these into the minibuffer when you wish to follow one.  The following
  786. functions in your `~/.emacs' file should do the trick.  It adds two
  787. keybindings to the GNUS article buffer.  The middle mouse button tries
  788. to follow a hypertext link.  This first tries to find any links that
  789. were fully-qualified with the HTML <A> and </A> (1) tags, otherwise it
  790. checks to see if the text around point is a naked URL (2).
  791.      (defun w3-maybe-follow-link-mouse (e)
  792.        "Maybe follow a hypertext link under point.
  793.      If there is no link under point, this will try using
  794.      url-get-url-at-point"
  795.        (interactive "e")
  796.        (save-excursion
  797.          (mouse-set-point e)
  798.          (w3-maybe-follow-link)))
  799.      
  800.      (defun w3-maybe-follow-link ()
  801.        "Maybe follow a hypertext link under point.
  802.      If there is no link under point, this will try using
  803.      url-get-url-at-point"
  804.        (interactive)
  805.        (require 'w3)
  806.        (if (not w3-setup-done) (w3-do-setup))
  807.        (let* ((zn  (w3-zone-at (point)))
  808.               (url1 (and zn (w3-zone-data zn)))
  809.               (url2 (url-get-url-at-point)))
  810.          (cond
  811.            (url1 (w3-follow-link))
  812.            ((and url2 (string-match url-nonrelative-link url2)) (w3-fetch url2))
  813.            (t (message "w3-maybe-follow-link got confused.")))))
  814.      
  815.      (add-hook 'gnus-article-mode-hook
  816.                (function
  817.                  (lambda ()
  818.                    (define-key gnus-article-mode-map [mouse-2]
  819.                                'w3-maybe-follow-link-mouse)
  820.                    (define-key gnus-article-mode-map "\r"
  821.                                'w3-maybe-follow-link))))
  822.      
  823.      (add-hook 'gnus-article-prepare-hook
  824.                (function
  825.                  (lambda ()
  826.                    (let ((w3-working-buffer gnus-article-buffer))
  827.                      (w3-build-links-list)))))
  828.    ---------- Footnotes ----------
  829.    (1)  Something akin to <a href="http://cs.indiana.edu/">
  830.    (2)  Similar to http://cs.indiana.edu/
  831.